/*
 * Theme.java  0.4.0 / Oct 25, 2010
 *
 * Copyright (c) 2010 - 2011, cute4j.com and contributors.
 *
 * This software is licensed under the LGPL version 2.1 license.
 * A copy of this license is included in the file LICENSE-LGPL.txt.
 */
package com.cute4j.swing.styles;

import com.cute4j.util.Utilities;

/**
 * The font and color theme of the style.
 *
 * @author Slobodan Vrkacevic
 * @version 0.4.0
 */
public abstract class Theme {

// Public Methods. -------------------------------------------------------------

  /**
   * Returns the name of the theme.
   *
   * @return the name of the theme
   */
  public abstract String getName();

  /**
   * Returns <tt>true</tt> if the theme is supported on the platform.
   *
   * @return <tt>true</tt> if the theme is supported on the platform
   */
  public abstract boolean isSupported();

  /**
   * Returns color palette.
   *
   * @return color palette
   */
  public abstract ColorPalette getColorPalette();

  /**
   * Returns font set.
   *
   * @return font set
   */
  public abstract FontSet getFontSet();

// Overridden Methods. ---------------------------------------------------------

  /**
   * {@inheritDoc}
   */
  public boolean equals(Object obj) {
    if (obj == this) {
      return true;
    }
    if ((obj != null) && (obj.getClass() == getClass())) {
      Theme theme = (Theme)obj;
      return (isSupported() == theme.isSupported()) &&
              Utilities.equals(getName(), theme.getName()) &&
              Utilities.equals(getColorPalette(), theme.getColorPalette()) &&
              Utilities.equals(getFontSet(), theme.getFontSet());
    }
    return false;
  }

  /**
   * {@inheritDoc}
   */
  public int hashCode() {
    int hashCode = 491;
    String name = getName();
    if (name != null) {
      hashCode = 439 * hashCode + name.hashCode();
    }
    ColorPalette colorPalette = getColorPalette();
    if (colorPalette != null) {
      hashCode = 439 * hashCode + colorPalette.hashCode();
    }
    FontSet fontSet = getFontSet();
    if (fontSet != null) {
      hashCode = 439 * hashCode + fontSet.hashCode();
    }
    return hashCode;
  }

  /**
   * {@inheritDoc}
   */
  public String toString() {
    return getName();
  }

}
